<?php
	$category_edit = array(
		'title' => 	'<div class="head">'.
			'<h1>' . __d('lil', 'Edit a Category', true) . '</h1>'.
			'</div>',
		'form' => array(
			'pre' => '<div class="form">',
			'post' => '</div>',
			'lines' => array(
				'form_start' => array(
					'class' => $form,
					'method' => 'create',
					'parameters' => array('model' => 'Category')
				),
				'id' => array(
					'class' => $form,
					'method' => 'hidden',
					'parameters' => array('field' => 'id')
				),
				'blog_id' => array(
					'class' => $form,
					'method' => 'hidden',
					'parameters' => array('field' => 'blog_id')
				),
				'referer' => array(
					'class' => $form,
					'method' => 'hidden',
					'parameters' => array('field' => 'referer')
				),
				'parent' => array(
					'class' => $form,
					'method' => 'input',
					'parameters' => array(
						'field' => 'parent_id',
						'options' => array(
							'label' => __d('lil', 'Parent', true) . ':',
							'options' => $parents,
							'empty'   => '--- ' . __d('lil', 'select a parent', true) . ' ---'
						)
					)
				),
				'name' => array(
					'class' => $form,
					'method' => 'input',
					'parameters' => array(
						'field' => 'name',
						'options' => array(
							'label' => __d('lil', 'Name', true) . ':',
							'error' => __d('lil', 'Category name is required.', true),
							'class' => 'big'
						)
					)
				),
				'submit' => array(
					'class' => $form,
					'method' => 'submit',
					'parameters' => array(
						'label' => __d('lil', 'Save', true)
					)
				),
				'form_end' => array(
					'class' => $form,
					'method' => 'end',
					'parameters' => array()
				),
			)
		)
	);
	
	$category_edit = $this->callPluginHandlers('form_edit_category', $category_edit);
	
	// form display begins
	echo $category_edit['title']; 
	
	echo $category_edit['form']['pre']; 
	foreach ($category_edit['form']['lines'] as $name => $line) {
		if (!empty($line['class'])) {
			$parameters = array();
			if (!empty($line['parameters'])) {
				$parameters = (array)$line['parameters'];
			}
			if (is_object($line['class'])) {
				$use_object =& $line['class'];
			} else {
				$use_object =& ${$line['class']};
			}
			echo call_user_func_array(array($use_object, $line['method']), $parameters);
		}
	}
	echo $category_edit['form']['post']; 
?>